package com.axonactive.yolo.service.implement;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import com.axonactive.yolo.dao.interfaces.AirportRepository;
import com.axonactive.yolo.domain.Airport;
import com.axonactive.yolo.service.interfaces.AirportService;

@PropertySource("classpath:messages.properties")
@Service
public class AirportServiceImplement implements AirportService {
	@Resource
	private Environment env;

	@Resource
	private AirportRepository airportRepository;

	@Override
//	@CacheEvict(value = "listAirportCache", allEntries = true)
	public List<Airport> findAll() {
		return airportRepository.findAll();
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#airportCode")
	public List<Airport> findByAirportCodeContaining(String airportCode) {
		return airportRepository
				.findByAirportCodeContainingOrderByAppLocationTypeDesc(airportCode);
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#cityCode")
	public List<Airport> findByCityCodeContaining(String cityCode) {
		return airportRepository
				.findByCityCodeContainingOrderByAppLocationTypeDesc(cityCode);
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#airportName")
	public List<Airport> findByAirportNameContaining(String airportName) {
		return airportRepository
				.findByAirportNameContainingOrderByAppLocationTypeDesc(airportName);
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#cityName")
	public List<Airport> findByCityNameContaining(String cityName) {
		return airportRepository
				.findByCityNameContainingOrderByAppLocationTypeDesc(cityName);
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#airportCode")
	public List<Airport> findByAirportCode(String airportCode) {
		return airportRepository.findByAirportCode(airportCode);
	}

	@Override
//	@Cacheable(value = "listAirportCache", key = "#appLocationType")
	public List<Airport> findByAppLocationType(String appLocationType) {
		return airportRepository.findByAppLocationType(appLocationType);
	}

}
